using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Commerce.Common
{
	/// <summary>
	/// Strongly-typed collection for the AdText class.
	/// </summary>
	[Serializable]
	public partial class AdTextCollection : ActiveList<AdText,AdTextCollection> 
	{	   
		public AdTextCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the CSK_Store_Ad_Text table.
	/// </summary>
	[Serializable]
	public partial class AdText : ActiveRecord<AdText>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public AdText()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public AdText(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

        
		public AdText(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public AdText(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }

		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("CSK_Store_Ad_Text", TableType.Table, DataService.GetInstance("dashCommerce"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarAdTextID = new TableSchema.TableColumn(schema);
				colvarAdTextID.ColumnName = "adTextID";
				colvarAdTextID.DataType = DbType.Int32;
				colvarAdTextID.MaxLength = 0;
				colvarAdTextID.AutoIncrement = true;
				colvarAdTextID.IsNullable = false;
				colvarAdTextID.IsPrimaryKey = true;
				colvarAdTextID.IsForeignKey = false;
				colvarAdTextID.IsReadOnly = false;
				colvarAdTextID.DefaultSetting = @"";
				colvarAdTextID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAdTextID);
				
				TableSchema.TableColumn colvarAdID = new TableSchema.TableColumn(schema);
				colvarAdID.ColumnName = "adID";
				colvarAdID.DataType = DbType.Int32;
				colvarAdID.MaxLength = 0;
				colvarAdID.AutoIncrement = false;
				colvarAdID.IsNullable = false;
				colvarAdID.IsPrimaryKey = false;
				colvarAdID.IsForeignKey = false;
				colvarAdID.IsReadOnly = false;
				colvarAdID.DefaultSetting = @"";
				colvarAdID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAdID);
				
				TableSchema.TableColumn colvarAdTextX = new TableSchema.TableColumn(schema);
				colvarAdTextX.ColumnName = "adText";
				colvarAdTextX.DataType = DbType.String;
				colvarAdTextX.MaxLength = 1500;
				colvarAdTextX.AutoIncrement = false;
				colvarAdTextX.IsNullable = false;
				colvarAdTextX.IsPrimaryKey = false;
				colvarAdTextX.IsForeignKey = false;
				colvarAdTextX.IsReadOnly = false;
				colvarAdTextX.DefaultSetting = @"";
				colvarAdTextX.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAdTextX);
				
				TableSchema.TableColumn colvarLanguage = new TableSchema.TableColumn(schema);
				colvarLanguage.ColumnName = "language";
				colvarLanguage.DataType = DbType.String;
				colvarLanguage.MaxLength = 10;
				colvarLanguage.AutoIncrement = false;
				colvarLanguage.IsNullable = false;
				colvarLanguage.IsPrimaryKey = false;
				colvarLanguage.IsForeignKey = false;
				colvarLanguage.IsReadOnly = false;
				
						colvarLanguage.DefaultSetting = @"(N'en-US')";
				colvarLanguage.ForeignKeyTableName = "";
				schema.Columns.Add(colvarLanguage);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["dashCommerce"].AddSchema("CSK_Store_Ad_Text",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("AdTextID")]
		public int AdTextID 
		{
			get { return GetColumnValue<int>(Columns.AdTextID); }

			set { SetColumnValue(Columns.AdTextID, value); }

		}

		  
		[XmlAttribute("AdID")]
		public int AdID 
		{
			get { return GetColumnValue<int>(Columns.AdID); }

			set { SetColumnValue(Columns.AdID, value); }

		}

		  
		[XmlAttribute("AdTextX")]
		public string AdTextX 
		{
			get { return GetColumnValue<string>(Columns.AdTextX); }

			set { SetColumnValue(Columns.AdTextX, value); }

		}

		  
		[XmlAttribute("Language")]
		public string Language 
		{
			get { return GetColumnValue<string>(Columns.Language); }

			set { SetColumnValue(Columns.Language, value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(int varAdID,string varAdTextX,string varLanguage)
		{
			AdText item = new AdText();
			
			item.AdID = varAdID;
			
			item.AdTextX = varAdTextX;
			
			item.Language = varLanguage;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varAdTextID,int varAdID,string varAdTextX,string varLanguage)
		{
			AdText item = new AdText();
			
				item.AdTextID = varAdTextID;
			
				item.AdID = varAdID;
			
				item.AdTextX = varAdTextX;
			
				item.Language = varLanguage;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn AdTextIDColumn
        {
            get { return Schema.Columns[0]; }

        }

        
        
        
        public static TableSchema.TableColumn AdIDColumn
        {
            get { return Schema.Columns[1]; }

        }

        
        
        
        public static TableSchema.TableColumn AdTextXColumn
        {
            get { return Schema.Columns[2]; }

        }

        
        
        
        public static TableSchema.TableColumn LanguageColumn
        {
            get { return Schema.Columns[3]; }

        }

        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string AdTextID = @"adTextID";
			 public static string AdID = @"adID";
			 public static string AdTextX = @"adText";
			 public static string Language = @"language";
						
		}

		#endregion
		
		
		
	}

}

